﻿using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MobileWebsiteGenerator.Entities;

namespace MobileWebsiteGenerator.Mapping
{
    public class CustomerWebsiteMap : EntityTypeConfiguration<CustomerWebsiteREL>
    {
        
            public CustomerWebsiteMap()
            {
                // Primary Key
                this.HasKey(t => t.Customer_Web_id);

                // Properties
                this.Property(t => t.Customer_Web_id)
                    .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

                // Table & Column Mappings
                this.ToTable("CustomerWebsiteREL");
                this.Property(t => t.Customer_Web_id).HasColumnName("Customer_Web_id");
                this.Property(t => t.Web_id).HasColumnName("Web_id");
                this.Property(t => t.Customer_id).HasColumnName("Customer_id");

                // Relationships
                this.HasRequired(t => t.Website)
                    .WithMany(t => t.CustomerWebsiteRels)
                    .HasForeignKey(d => d.Web_id);

                this.HasRequired(t => t.Customer)
                    .WithMany(t => t.CustomerWebsiteRels)
                    .HasForeignKey(d => d.Customer_id);

            }
        }
    }
